<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商家修改密码</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
	name="viewport">

<link rel="stylesheet"
	href="seller/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="seller/plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
	href="seller/plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="seller/css/style.css">
<script src="seller/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="seller/plugins/bootstrap/js/bootstrap.min.js"></script>

<script type="text/javascript">
 
     function checkOldPassword(dbpassword){
		var checkoldpwd;
		var oldPassword = document.getElementById("oldPassword").value;//用户输入的原来的旧密码
		var content = document.getElementById("content");
		if(oldPassword == null || "" == oldPassword){
			content.innerHTML = "原密码不能为空！";
			checkoldpwd = false;
		}else if(dbpassword != oldPassword){
			content.innerHTML = "原密码和该用户密码不匹配！";
			checkoldpwd = false;
		}else{
			content.innerHTML = "";
			checkoldpwd = true;
		}
		return checkoldpwd;
	}
	

	function checkNewPassword1(dbpassword){
		var checknewpwd1;
		var newPassword = document.getElementById("newPassword1").value;//得到用户输入的新密码
		var content = document.getElementById("content");
		//规则为由8到20位数字字母组合或者数字特殊符号组合或者字母特殊符号组合，不能纯数字和纯字母和纯特殊字符
     	var reg= /((?=.*[a-z])(?=.*\d)|(?=[a-z])(?=.*[#@!~%^&*])|(?=.*\d)(?=.*[#@!~%^&*]))[a-z\d#@!~%^&*]{8,20}/i;
		var flag = reg.test(newPassword);
		if(newPassword == null || ""==newPassword){
			content.innerHTML = "新密码不能为空！";
			checknewpwd1 = false;
			return false;
		}else if(dbpassword == newPassword ){
			content.innerHTML = "新密码和旧密码相同！";
			checknewpwd1 = false;
			return false;
		}else{
			content.innerHTML = "";
			checknewpwd1 = true;
		}
		if(flag==false){
			content.innerHTML = "新密码输入不合法，8-20位，不能是纯数字或纯字母！";
			checknewpwd1 = false;
		}else{
			content.innerHTML = "";
			checknewpwd1 = true;
		}
		return checknewpwd1;
		
	}
	
	function checkNewPassword2(){
		var checknewpwd2;
		var newPassword2 = document.getElementById("newPassword2").value;
		var newPassword = document.getElementById("newPassword1").value;
		var content = document.getElementById("content");
		if(newPassword2 == null || newPassword2 == ""){
			content.innerHTML = "确认新密码不能为空！";
			checknewpwd2 = false;
			return false;
		}else{
			content.innerHTML = "";
			checknewpwd2 = true;
		}
		if(newPassword2!=newPassword){
			content.innerHTML = "两次输入的新密码不一致！";
			checknewpwd2 = false;
		}else{
			content.innerHTML = "";
			checknewpwd2 = true;
		}
		return checknewpwd2;
		
	}

	function check(dbpassword){
		var flag = checkOldPassword(dbpassword) && checkNewPassword1(dbpassword) && checkNewPassword2();
		return flag;
	}

</script>

</head>

<body class="hold-transition skin-red sidebar-mini">

   <%--  <h2>密码：${customSeller.password}</h2> --%>
	<form action="updatePassword.action" method="post" onsubmit="return check('${customSeller.password}')" >
		<!-- 正文区域 -->
		<section class="content">

		<div class="box-body">

			<!--tab页-->
			<div class="nav-tabs-custom">

				<!--tab头-->
				<ul class="nav nav-tabs">

					<li class="active"><a href="#home" data-toggle="tab">修改密码</a></li>
					<li ><div style="margin-left: 500" id="content" ></div> </li>
				</ul>
				<!--tab头/-->

				<!--tab内容-->
				<div class="tab-content">

					<!--表单内容-->
					<div class="tab-pane active" id="home">
						<div class="row data-type">
							<div class="col-md-2 title">原密码</div>
							<div class="col-md-10 data">          <!-- onblur="checkOldPassword(this.value)" -->
								<input type="password" class="form-control"  id="oldPassword"  onblur="checkOldPassword('${customSeller.password}')"
									placeholder="原密码"  value="">
							</div>
						
							<div class="col-md-2 title">新密码</div>
							<div class="col-md-10 data">         <!-- onblur="checkNewPassword1()" -->
								<input type="password" name="password" class="form-control" id="newPassword1" onblur="checkNewPassword1('${customSeller.password}')"
									placeholder="新密码"  value="">
							</div>

							<div class="col-md-2 title">确认新密码</div>
							<div class="col-md-10 data">          <!-- onblur="checkNewPassword2()" -->
								<input type="password" class="form-control" id="newPassword2" onblur="checkNewPassword2()"
									placeholder="确认新密码"  value="">
							</div>
						</div>
					</div>

				</div>
				<!--tab内容/-->
				<!--表单内容/-->
			</div>

		</div>
		<div class="btn-toolbar list-toolbar">
			<button class="btn btn-primary" >
				<i class="fa fa-save"></i>提交
			</button>
			<input data-toggle="modal" type="reset" class="btn btn-danger" value="重置" ></input>
		</div>

		</section>
		<!-- 正文区域 /-->

	</form>
</body>

</html>